const mongoose = require('mongoose');
const { Article } = require('../../model/article')

module.exports = async (req, res) => {
    var id = req.params.id
    // console.log(id);
    try {
        var data = await Article.findOneAndDelete({ _id: id })
        // console.log(data);
    } catch(err){
        // console.log(err);
        return res.send({
            data: null,
            meta: {
                status: 400,
                msg: '删除失败'
            }
        })
    }
    if(data===null){
        return res.send({
            data: null,
            meta: {
                status: 400,
                msg: '删除失败'
            }
        })
    }
    res.send({
        data,
        meta: {
            status: 204,
            msg: '删除成功'
        }
    })

}